﻿using JTC.Genetics._Interfaces;
using JTC.Genetics.Replication;
using JTC.Genetics.Replication._Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JTC.Genetics._Abstract
{
    public abstract class PlantCell : Eukaryote, 
        IPlantCell, 
        IReplicator
    {
        private IPlantCellReplicator _replicator;
        public PlantCell(IPlantCellReplicator replicator)
        {
            _replicator = replicator;
        }

        public Chloroplast Chloroplasts { get { return new Chloroplast(); } }
        public object Wall { get { return new object(); } }

        #region IReplicator Members

        ICellular IReplicator.Replicate()
        {
            ((IReplicator)this).Mitosis();
            ((IReplicator)this).CompleteDivision();

            var child = this.Copy();
            child.Parent = this;
            return child;
        }

        void IReplicator.Mitosis()
        {
            _replicator.Interphase();
            _replicator.Preprophase();
            _replicator.Prophase();
            _replicator.Prometaphase();
            _replicator.Metaphase();
            _replicator.Anaphase();
            _replicator.Telophase();
    
            if(MitosisComplete!=null)
                MitosisComplete(this, new EventArgs());
        }

        void IReplicator.CompleteDivision()
        {
            _replicator.Cytokinesis();
        }

        public event EventHandler MitosisComplete;

        #endregion
    }
}
